<?php
/*
**查询青岛海底世界已过期与未使用，更新订单状态
**2015-09-10 pm
**User By  PZP
*/
// $time_1 = microtime(true);
include('/var/www/html/new/d/module/api/QD_underwater_world/QD.class.php');
include('/var/www/html/new/d/module/api/function.class.php');
if (!class_exists("go_sql")){
	include("/var/www/html/new/conf/le.je");
	$le=new go_sql();
	$le->connect();
}

$QD = new QD_underW_World();
$PFT_infunction = new AllFunction();
$selorder = "select apiCode,pftOrder,tempOrder from all_api_order where coopB=4 and oStatus= 0";
$GLOBALS['le']->query($selorder);
while($row = $GLOBALS['le']->fetch_assoc()){
	$Orders[] = $row;
}

foreach($Orders  as $arr){
	$getOrderStatus = $QD->GetAllOrderStatus($arr['apiCode']);	
	$OrderStatus = $getOrderStatus[0]['OrderStatus'];
	if($OrderStatus == 'O'){ //线下已换票，需更新票付通状态
		$pft_order_xml = $PFT_infunction->Select_PFTorder($arr['pftOrder']);	
		$chkIns = 499;
		if((string)$pft_order_xml->Rec->UUstatus==2) $chkIns = 498;
		$UUordernum = (string)$pft_order_xml->Rec->UUordernum;
		$UUsalerid = (string)$pft_order_xml->Rec->UUsalerid;
		$UUcode = (string)$pft_order_xml->Rec->UUcode;
		$r = $PFT_infunction->Unified_Check_IN($UUsalerid,$UUcode,date('Y-m-d H:i:s'),$chkIns);
		if($r == 100 || $r == 293 ) {
			$PFT_infunction->logfile('4|'.$UUordernum.'|'.$arr['tempOrder'].'|'.$arr['apiCode']."|".$r,"check_s");
			$selorder = "update all_api_order  set oStatus=1 where pftOrder='$UUordernum' limit 1";
			$GLOBALS['le']->query($selorder);
		}
		else
			$PFT_infunction->logfile('4|'.$UUordernum.'|'.$arr['tempOrder'].'|'.$arr['apiCode']."|".$r,"check_f");
	}
	usleep(100);
}
?>